package com.xli.mis.tablecategory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xli.mis.tablecategory.entity.TableCategory;
import com.xli.mis.tablecategory.mapper.TableCategoryMapper;
import com.xli.mis.tablecategory.service.ITableCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TableCategoryServiceImpl extends ServiceImpl<TableCategoryMapper, TableCategory> implements ITableCategoryService {

    @Override
    public boolean insert(TableCategory tableCategory) {
        return this.save(tableCategory);
    }

    @Override
    public boolean delete(Long id) {
        return this.removeById(id);
    }

    @Override
    public boolean update(TableCategory tableCategory) {
        return this.updateById(tableCategory);
    }

    @Override
    public TableCategory find(Long id) {
        return this.getById(id);
    }

    @Override
    public long findCount(QueryWrapper<TableCategory> qw) {
        return this.count(qw);
    }

    @Override
    public List<TableCategory> findList(QueryWrapper<TableCategory> qw) {
        return this.list(qw);
    }

    @Override
    public Page<TableCategory> findList(QueryWrapper<TableCategory> qw, long current, long size) {
        return this.page(new Page<>(current, size), qw);
    }

    @Override
    public TableCategory findByName(String name) {
        QueryWrapper<TableCategory> qw = new QueryWrapper<>();
        qw.lambda().eq(TableCategory::getCategory_name,name);
        return this.getOne(qw,false);
    }
}
